package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SeatImage;
import com.ruoyi.system.service.ISeatimageService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 坐席图片Controller
 * 
 * @author ruoyi
 * @date 2025-04-21
 */
@Controller
@RequestMapping("/system/seatimage")
public class SeatImageController extends BaseController
{
    private String prefix = "system/seatimage";

    @Autowired
    private ISeatimageService seatimageService;

    @RequiresPermissions("system:seatimage:view")
    @GetMapping()
    public String seatimage()
    {
        return prefix + "/seatimage";
    }

    /**
     * 查询坐席图片列表
     */
    @RequiresPermissions("system:seatimage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SeatImage seatimage)
    {
        startPage();
        List<SeatImage> list = seatimageService.selectSeatimageList(seatimage);
        return getDataTable(list);
    }

    /**
     * 导出坐席图片列表
     */
    @RequiresPermissions("system:seatimage:export")
    @Log(title = "坐席图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SeatImage seatimage)
    {
        List<SeatImage> list = seatimageService.selectSeatimageList(seatimage);
        ExcelUtil<SeatImage> util = new ExcelUtil<SeatImage>(SeatImage.class);
        return util.exportExcel(list, "坐席图片数据");
    }

    /**
     * 新增坐席图片
     */
    @RequiresPermissions("system:seatimage:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存坐席图片
     */
    @RequiresPermissions("system:seatimage:add")
    @Log(title = "坐席图片", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SeatImage seatimage)
    {
        return toAjax(seatimageService.insertSeatimage(seatimage));
    }

    /**
     * 修改坐席图片
     */
    @RequiresPermissions("system:seatimage:edit")
    @GetMapping("/edit/{imagePath}")
    public String edit(@PathVariable("imagePath") String imagePath, ModelMap mmap)
    {
        SeatImage seatimage = seatimageService.selectSeatimageByImagePath(imagePath);
        mmap.put("seatimage", seatimage);
        return prefix + "/edit";
    }

    /**
     * 修改保存坐席图片
     */
    @RequiresPermissions("system:seatimage:edit")
    @Log(title = "坐席图片", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SeatImage seatimage)
    {
        return toAjax(seatimageService.updateSeatimage(seatimage));
    }

    /**
     * 删除坐席图片
     */
    @RequiresPermissions("system:seatimage:remove")
    @Log(title = "坐席图片", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(seatimageService.deleteSeatimageByImagePaths(ids));
    }
}
